package it.gat.webservice.resource.impl;

import java.sql.SQLException;
import java.util.List;

import it.gat.dao.RapportoInterventoDAO;
import it.gat.model.RapportoIntervento;
import it.gat.util.dao.DAOFactory;
import it.gat.webservice.utils.Impostazioni;

import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;

public class RapportiInterventoClienteResource extends ServerResource {

	@Get
	public RapportoIntervento[] getAll() {
		DAOFactory daoFactory = DAOFactory.getDAOFactory(Integer.parseInt(Impostazioni.getProperty("DB_TYPE")));
		RapportoInterventoDAO rapportoInterventoDAO = daoFactory.getRapportoInterventoDAO();
		List<RapportoIntervento> clienti;
		try {
			clienti = rapportoInterventoDAO.retrieveCliente(Integer.parseInt(getRequestAttributes().get("id").toString()));
		} catch (SQLException e) {
			return null;
		}
		return clienti.toArray(new RapportoIntervento[0]);
	}
	

}
